﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Net.Mail;
using System.Net;

namespace Util
{
    public static class EMail
    {
        private static MailMessage mail;
        private static SmtpClient smtp;
        private static NetworkCredential kullaniciDogrulama;

        private static void mailSettings()
        { //mail ayarları

            /*KullaniciTableAdapters.MailAyarlariTableAdapter ayarAd = new KullaniciTableAdapters.MailAyarlariTableAdapter();
            Kullanici.MailAyarlariDataTable ayarDt = ayarAd.GetData();
            mail = new MailMessage();
            kullaniciDogrulama = new NetworkCredential();
            smtp = new SmtpClient();
            mail.From = new MailAddress(ayarDt.Rows[0]["ADRES"].ToString());
            mail.IsBodyHtml = true;
            kullaniciDogrulama.UserName = ayarDt.Rows[0]["KULLANICI_ADI"].ToString();
            kullaniciDogrulama.Password = ayarDt.Rows[0]["SIFRE"].ToString();
            smtp.Host = ayarDt.Rows[0]["HOST"].ToString();
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = kullaniciDogrulama;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;*/
        }

        public static bool sendMail(string[] kullanicilar, string[] Veriler)
        { //toplu veya tek mail gönderme fonksiyonu

            /*string to;
            mailAyarlari();
            mail.Subject = Veriler[0];
            mail.Body = Veriler[1];
            for (int i = 0; i < kullanicilar.Length; i++)
            {
                mail.To.Clear();
                try
                {
                    to = kullanicilar[i];
                    mail.To.Add(to);
                    try
                    {
                        smtp.Send(mail);
                    }
                    catch (SmtpException e)
                    {
                        //mail gönderilemedi hatası
                    }
                }
                catch
                {
                    //mail yanlış hatası
                }
            }*/
            return true;
        }
    }
}